//GC垃圾回收前的回调函数
const finalizationRegistry = new FinalizationRegistry((value) => {
  console.log(value, '被销毁了！');
});
// let obj = { name: 'djw' };
// let info = { info: 'hahahaah' };
// finalizationRegistry.register(obj, 'obj');
// finalizationRegistry.register(info, 'info');
// obj = null;
// info = null;

let obj = { name: 'djw' };
let info = obj;
// let info = new WeakRef(obj);
finalizationRegistry.register(obj, 'obj');
obj = null;
setTimeout(() => {
  //   console.log(info.deref().name);
  console.log(info.name);
}, 10000);
